package com.tianji.jersey.subresource;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.PathSegment;
import javax.ws.rs.core.UriInfo;


@Path("/c/{id}")
public class ChildResource {
	 @Context UriInfo uriInfo;
	 @Context HttpServletRequest servletRequest;
	 @Path("{id}")
	 @GET
	 @Produces("text/plain")
     public String getSubResource( @Context UriInfo uriInfo,@PathParam("id") String id) {
		 System.out.println("child resource---->"+id);
		 System.out.println("request--->"+uriInfo);
		 MultivaluedMap<String, String> callback = uriInfo.getQueryParameters();
		 
		 MultivaluedMap<String,String> params = uriInfo.getPathParameters();
		 List<PathSegment> s =uriInfo.getPathSegments();
		 for(PathSegment seq : s){
			 System.out.println("sqp============>"+seq.getPath());
		 }
		 printMap(callback);
		 System.out.println("--------------------------------------------");
		 printMap(params);
		 String p1 = "123"+callback.get("callback")+"abc";
		 System.out.println(callback.size());
    	 System.out.println("=222222====================>"+id+"===="+p1);
         return "bbbbbb";
     }
	 private void printMap(MultivaluedMap<String,String> callback){
		 for(Object key : callback.keySet()){
			 System.out.println("key:"+key+"--"+callback.get(key).get(0));
		 }
	 }
}
